home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <iostream.h>
- #include <stdlib.h>
- #include <fstream.h>
- #include <iomanip.h>
- #include <conio.h>
- #include "table.h"
- #include "record.h"
-
-
- struct AFILE
- { // Structure...
- char name[21];
- double amount;
- int items;
- };
-
-
- AFILE afile;
-
-
- main()
- {
- int total_items = 0;
- double total_amount = 0;
-
- int stat;
- Record record("ascii2.fld"); // Record Object passing .fld file
-
-
- Table table("ascii2.txt", &record); // Table Object passing ascii file
- // name, and pointer to record
- // object...
-
-
- int index = record.getFieldNum("AMOUNT"); // Init. Index passing field
- // name to index on...
-
- int si = table.openIndex(&index,1); // openIndex passing pointer
- // to index, and number of
- // fields indexing on...
-
-
- clrscr();
-
- //** For Loop to read through the records...
- //** Pass 'si' handle for sorted ordering, nothing for non sorted...
- for (stat = table.gotoFirst(si); stat==TBL_OK; stat = table.gotoNext(si))
- {
- table.Get(); // Get record into buffer.
-
- record.getField("NAME", afile.name); // Read fields
- record.getField("AMOUNT", afile.amount);
- record.getField("ITEMS", afile.items);
-
- total_items += afile.items;
- total_amount += afile.amount;
-
- printf("Name : %s\n", afile.name); // Display
- printf("Amount : %8.2lf\n", afile.amount);
- printf("Items : %d\n", afile.items);
- printf("______________________________\n\n");
- }
-
- printf("Grand Total Amount = %11.2lf\n", total_amount);
- printf("Grand Total Items = %d\n\n", total_items);
-
- table.gotoFirst(si);
- return 0;
- }
-
-